package com.company.sendemo.basics.acConditionalBranching.operator;

public class Detail {
    private static int x = 100;

    public static void main(String[] args) {
        int a = 3;
        //TODO 逻辑运算符 ++ -- 在前 先运算后赋值（与空格无关）
        //TODO 逻辑运算符 ++ -- 在后 先赋值后运算（与空格无关）
        System.out.println(++a); //        ++a;
        System.out.println("a = " + a);
        System.out.println(++a);//        ++ a;
        System.out.println("a = " + a);
        System.out.println(a++);//        a ++;
        System.out.println("a = " + a);
        System.out.println(a++);//        a++;
        System.out.println("a = " + a);

        System.out.println(a--);//        a --;
        System.out.println("a = " + a);
        System.out.println(a--);//        a--;
        System.out.println("a = " + a);
        System.out.println(--a);//        -- a;
        System.out.println("a = " + a);
        System.out.println(--a);//        --a;
        System.out.println("a = " + a);
        System.out.println();


        //TODO 不加 break; 从匹配的对应case一直往下走(包括default也执行)
        int result = 0;
        int i = 2;
        switch (i) {
            case 1:
                result = result + i;
            case 2:
                result = result + i * 2;
            case 3:
                result = result + i * 3;
            default:
                result = result + 1;
        }
        System.out.println(result);
        result = 0;
        i = 2;
        switch (i) {
            case 1:
                result = result + i;
                break;
            case 2:
                result = result + i * 2;
                break;
            case 3:
                result = result + i * 3;
                break;
        }
        System.out.println(result);
        System.out.println();


        Detail detail = new Detail();
        detail.x++;
        System.out.println(Detail.x);//101 打印hs1 为地址值
        Detail detail1 = new Detail();
        detail1.x++;
        System.out.println(Detail.x);//102
        detail = new Detail();
        detail.x++;
        System.out.println(Detail.x);//103
        Detail.x--;
        System.out.println(Detail.x);//102
    }
}
